package com.warm;

import com.warm.core.config.WarmConfig;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.EventListener;

/**
 * 启动后文档指引打印
 *
 * @author warm
 */
@Component
public class AppLoadEndEventListener implements EventListener<AppLoadEndEvent> {
    @Inject
    private WarmConfig warmConfig;

    @Override
    public void onEvent(AppLoadEndEvent event) {
        System.out.printf("""
                 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
                |                                                                         |
                |                             _ooOoo_                                     |
                |                            o8888888o                                    |
                |                            88" . "88                                    |
                |                            (| ^_^ |)                                    |
                |                            O\\  =  /O                                    |
                |                         ____/`---'\\____                                 |
                |                       .'  \\\\|     |//  `.                               |
                |                      /  \\\\|||  :  |||//  \\                              |
                |                     /  _||||| -:- |||||-  \\                             |
                |                     |   | \\\\\\  -  /// |   |                             |
                |                     | \\_|  ''\\---/''  |   |                             |
                |                     \\  .-\\__  `-`  ___/-. /                             |
                |                   ___`. .'  /--.--\\  `. . ___                           |
                |                 ."" '<  `.___\\_<|>_/___.'  >'"".                        |
                |               | | :  `- \\`.;`\\ _ /`;.`/ - ` : | |                       |
                |               \\  \\ `-.   \\_ __\\ /__ _/   .-` /  /                       |
                |         ========`-.____`-.___\\_____/___.-`____.-'========               |
                |                              `=---='                                    |
                |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^              |
                |                佛祖保佑       永不宕机      永无BUG                         |
                |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
                |                                                                         |
                |       启动成功   %s环境              　                                   |
                |                                                                         |
                | 	    warm Version: %s                                               |
                | 	    Solon Version: %s                                           |
                |       接口文档地址：http://localhost:%s/doc.html                        |
                |                                                                         |
                |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
                %n""", Solon.cfg().env(), warmConfig.getVersion(), Solon.version(), warmConfig.getPort());
    }
}